package com.main.ok.push;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.greenline.push.services.PushCenterCommonService;

/**
 * 推送中心接口使用demo
 * 
 * @author shuai.zuo
 * 
 */
public class PushDemo {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

        /**
         * 获取服务
         */
        PushCenterCommonService pushService = (PushCenterCommonService) ctx.getBean("pushService");
        Map<String, String> tmp = new HashMap<String, String>();
        tmp.put("content", "this message is from push-center.-->zuoshuai");
        tmp.put("title", "hello,thx");

        /*--------------------------------------------
        |               M E T H O D S     主要用到的是点对点推送,其他的暂未接入    |
        =================================================*/
        
        /**
         * 点对点推送[推荐使用]
         */
        com.greenline.push.services.dto.ResponseDTO<Boolean> results = pushService.send(12121343l, "echatCommonPushTemplate",
                "echat_relative_domain", tmp, null);
        /**
         * 集合推送[后台会转化称点对点]
         */
        List<Long> userlist = new ArrayList<Long>();
        userlist.add(12549300l);

        /*
         * com.greenline.push.services.dto.ResponseDTO<Boolean> results =
         * service.sendList(userlist, "echatCommonPushTemplate",
         * "echat_relative_domain", tmp, null); // echat
         */

        /**
         * 7 建群
         */
        // com.greenline.push.services.dto.ResponseDTO<Long> results =
        // service.createGroup("zuoshuai-group-dev2", 5560966l);
        /**
         * 订阅
         */
        // com.greenline.push.services.dto.ResponseDTO<Boolean> results
        // = service.subscribe(16l, 5560966l);
        /**
         * 批量订阅
         */
        // List<Long> userids = new ArrayList<Long>();
        // userids.add(11792341l);
        // userids.add(12121343l);
        // userids.add(12121252l);
        // com.greenline.push.services.dto.ResponseDTO<Boolean> results
        // = service.subscribe(16l, userids);
        /**
         * 取消订阅
         */
        // com.greenline.push.services.dto.ResponseDTO<Boolean> results
        // = service.unsubscribe(16l, 55609616l);
        /**
         * 群推送
         */
        // com.greenline.push.services.dto.ResponseDTO<Boolean> results
        // = service.sendGroup(16l, "16", "17", tmp);
        /**
         * 获取定义[获取模版的定义]
         */
        // com.greenline.push.services.dto.ResponseDTO<String> results =
        // service.getBizDefine("weiyi-patient");
        System.out.println(Thread.currentThread().getName() + "[>>>]" + results.getMessage() + "--" + results.getErrorMsg() + "=="
                + results.getDataResult());

    }

}
